package com.xxjz.sc.mapper.user;

import com.xxjz.sc.bean.user.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Select("select * from user")
    public List<User> getAllUser();

    @Select("select * from user where uid = #{uid}")
    public User getUserById(Integer uid);

    @Delete("delete from user where uid = #{uid}")
    public int deleteUserById(Integer uid);

    @Options(useGeneratedKeys = true,keyProperty = "uid")
    @Insert("INSERT INTO user(`username`, `Pass`, `UserRealname`, `Pic`, `Sex`, `Email`, `Birth`, `HomeCountry`, `HomeProvice`, " +
            "`HomeCity`, `HomeXian`, `HomeDetailAddr`, `homeCun`) VALUES ( #{username}, #{Pass},#{UserRealname},#{Pic},#{Sex},#{Email}," +
            "#{Birth},#{HomeCountry},#{HomeProvice},#{HomeCity},#{HomeXian},#{HomeDetailAddr},#{homeCun} );")
    public int insertUser(User user);

    @Update("update user set  username=#{username}, Pass=#{Pass},UserRealname=#{UserRealname},Pic=#{Pic},#Sex={Sex},Email=#{Email}," +
            "Birth=#{Birth},HomeCountry=#{HomeCountry},HomeProvice=#{HomeProvice},HomeCity=#{HomeCity},HomeXian=#{HomeXian}," +
            "HomeDetailAddr=#{HomeDetailAddr},homeCun=#{homeCun} where id = #{uid} ;")
    public int updateUserById(User user);
}
